package com.sxz.sbs.module.performance.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.performance.mode.MonthRankBean;
import com.sxz.sbs.module.performance.view.MonthRankView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;

/**
 * 月榜
 * @author tian
 */

public class MonthRankPresenter extends RxPresenter<MonthRankView>{
    /**
     * 获取月榜
     * @param map
     */
    public void getMonthRank (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getMonthRank(map)
                .compose(RxUtil.<MonthRankBean>handleResult())
                .subscribeWith(new RxSubscriber<MonthRankBean>(mView){
                    @Override
                    public void onNext(MonthRankBean data) {
                        mView.onGetMothRankSuccess(data);
                    }
                })
        );
    }
    /**
     * 获取月榜
     * @param map
     */
    public void addMonthPraise (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().addMonthPraise(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onAddMonthPraiseSuccess();
                    }
                })
        );
    }
}
